# _*_coding:utf-8 _*_
# @Time   :2020/6/25

from rest_framework.permissions import BasePermission


# 自定义权限类
class NeedPermission(BasePermission):
    message = "权限不足"  # 重写返回提示信息

    def has_permission(self, request, view):
        # 进行判断
        user = request.user
        # 拥有staff权限才能访问接口
        if user and user.is_staff:
            # 表示有权访问
            return True
        return False
